package cn.itcast.service.cargo.impl;


import cn.itcast.dao.cargo.ContractDao;
import cn.itcast.dao.cargo.ExportProductDao;
import cn.itcast.dao.cargo.ExtCproductDao;
import cn.itcast.domain.cargo.*;
import cn.itcast.service.cargo.ExportProductService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ExportProductServiceImpl implements ExportProductService {


    @Autowired
    private ExportProductDao exportProductDao;


    @Autowired
    private ContractDao contractDao;


    @Autowired
    private ExtCproductDao extCproductDao;

    /*
     报运商品分页
     */
    @Override
    public PageInfo<ExportProduct> findByPage(ExportProductExample exportProductExample, int pageNum, int pageSize) {

        //设置页面大小
        PageHelper.startPage(pageNum,pageSize);

        //查询全部
        List<ExportProduct> exportProductList = exportProductDao.selectByExample(exportProductExample);

        //封装PageInfo对象
        PageInfo<ExportProduct> pageInfo = new PageInfo<>(exportProductList);

        return pageInfo;
    }

    //查询全部
    @Override
    public List<ExportProduct> findAll(ExportProductExample exportProductExample) {

        List<ExportProduct> exportProductList = exportProductDao.selectByExample(exportProductExample);

        return exportProductList;
    }

    //根据主键查询
    @Override
    public ExportProduct findById(String id) {

        ExportProduct exportProduct = exportProductDao.selectByPrimaryKey(id);
        return exportProduct;
    }


    //保存报运商品
    @Override
    public void save(ExportProduct exportProduct) {

        //2.插入报运商品的数据
        exportProductDao.insertSelective(exportProduct);

    }

    //更新报运商品
    @Override
    public void update(ExportProduct exportProduct) {
        //2.更新报运商品的数据
        exportProductDao.updateByPrimaryKeySelective(exportProduct);

    }

    //删除报运商品
    @Override
    public void delete(String id) {
        //1.删除报运商品
        exportProductDao.deleteByPrimaryKey(id);

    }


}
